<?php
$rs = $this->lastResult;

//total sum
$rsT = $this->db->queryToArray("select SUM(VALOR) TOTAL from ($this->lastQuery) A");
$total = count($rsT) > 0 ? $rsT[0]["TOTAL"] : 0;
$total = isEmpty($total) ? 0 : $total;
?>
<div class="dttb">
    <input type="hidden" name="page" id="page" />
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <th scope="col">ESTUDIANTE/BENEF</th>
                <th scope="col">TIPO CTA.</th>
                <th scope="col">ID COBRO</th>
                <th scope="col">TIPO CARGO</th>
                <th scope="col">FECHA EMISION</th>
                <th scope="col">PARTIDA</th>        
                <th scope="col">ESTADO</th>        
                <th scope="col">VALOR</th>        
            </tr>
        </thead>
        <tbody>    
            <?php if (count($rs) > 0) {
                foreach ($rs as $r) { ?>
                    <tr>
                        <td><?php echo $r["FK_ESTUDIANTE"] . ' - ' . $r["Nombre_cuenta"] ?></td>
                        <td><?php echo $r["tcuenta"] ?></td>
                        <td><?php echo $r["ID"] ?></td>
                        <td><?php echo htmlentities($r["DESCRIPCION"]); ?></td>
                        <td><?php echo date("d/m/Y", strtotime($r["fecha_emision"])) ?></td>
                        <td><?php echo $r["PARTIDA_CARGOS"] ?></td>
                        <td><?php echo $r["ESTADO"] ?></td>
                        <td><?php echo number_format($r["VALOR"], 2); ?></td>  
                    </tr>
                <?php }
            } else { ?>
                <tr>
                    <td colspan="5">No posee informacion!</td>
                </tr>  
            <?php } ?>
        </tbody>
        <tfoot>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <th>Total Cobrado</th>
                <th><?php echo number_format($total, 2); ?></th>
            </tr>
        </tfoot>
    </table>
</div>